<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Say Good Bye when leaves the site</title>
		<script type="text/javascript">
		
			window.onbeforeunload = sayGoodBye;
			
			function sayGoodBye() {
				var name = document.getElementById('name').value;
				alert ("Good Bye " + name);
			}
		</script>
	</head>
	<body>
		<label>Enter your name:</label><input type="text" id="name"><br>
	</body>
</html>